package cn.mengfly.algorithm.collection.stack;

/**
 * stack
 *
 * @author wangp
 */
public interface Stack<T> extends Iterable<T> {


    /**
     * push a element to stack head
     *
     * @param t element
     */
    void push(T t);

    /**
     * pop element from stack, if stack is empty, this method will return null
     *
     * @return next head element or null when stack is empty
     */
    T pop();

    /**
     * return the last added stack element, and not pop it
     *
     * @return last added element
     */
    T peak();

    /**
     * Stack is Empty
     *
     * @return Stack is Empty
     */
    boolean isEmpty();

    /**
     * Stack contains element count
     *
     * @return Stack size
     */
    int size();

    /**
     * clear item
     */
    void clear();
}
